﻿using Glorysoft.Auto.Xfw;
using Glorysoft.Auto.Xfw.Contract;
using Glorysoft.Auto.Xfw.Entities;
using Glorysoft.EAP.Core;
using Glorysoft.EAP.Core.Entities;
using Glorysoft.EAP.Core.Enums;
using Glorysoft.EAP.EAPClient.Model;
using Glorysoft.EAP.EAPClient.View;
using Microsoft.Extensions.Configuration;
using Serilog.Core;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace Glorysoft.EAP.EAPClient
{
    public class EAPClient
    {
        private const string MsgNameSendConnect = "SendConnect";
        private const string MsgNameSendRemoveLot = "SendRemoveLot";
        private const string MsgNameChangeLanguage = "ChangeLanguage";
        private const string MsgNameTrackOutByUser = "TrackOutByUser";
        private const string MsgNameLogin = "Login";
        private const string MsgNameGetCarrierLotInfo = "GetCarrierLotInfo";
        private const string MsgNameStartProgram = "StartProcess";
        private const string MsgNameSendStopProcess = "StopProcess";
        private const string MsgNameSelectWaferID = "SelectWaferID";
        private const string MsgNameNeedleMarkDetectionWaferId = "SelectNeedleMarkDetectionWaferId";
        private const string MsgNameClearAlarm = "ClearAlarm";
        private const string MsgNameSendNeedMardUserInfo = "SendNeedMardUserInfo";
        private IMqContext context;
        private string requestClient = Dict.Current.EAPName;
        protected readonly IConfiguration Config;
        private const string HeartBeat = "HeartBeat";

        public EAPClient()
        {
            Config = XfwContext.Configuration as IConfiguration;
        }
        public Model.RunService ClientInfo
        {
            get
            {
                return Model.RunService.Current;
            }
        }
        public Return SendConnect(ConnectModel _model)
        {
            var retMsg = new Return();
            try
            {
                EAPClient cq = new EAPClient();
                var request = new Request() { Header = XfwUtils.CreateHeader(MsgNameSendConnect, requestClient) };
                request.Body.AddString(CItems.EqpID, _model.EQPID);
                var strText = XfwUtils.Serialization(request.GetSerializationObject());
                context = XfwContext.GetMqContextByEAP(requestClient);
                var res = context.Request(strText);
                if (res != null)
                {
                    retMsg = res.GetReturnObject();
                }
                XfwContext.EapLogger.Information($"EAPClient.SendConnect() Execute. ReturnCode: {retMsg.ReturnCode}, ReturnMessage: {retMsg.ReturnMessage}");
            }
            catch (Exception ex)
            {
                retMsg.SetReturnNG(ex.Message);
                XfwContext.EapLogger.Error(ex, $"EAPClient.SendConnect() Execute Error.");
            }
            return retMsg;
        }
        /// <summary>
        /// 在客户端手动删除lot信息
        /// </summary>
        /// <param name="eqpId"></param>
        /// <param name="portId"></param>
        /// <returns></returns>
        /// 
        public void SendWaferEnd(XfwArgs xfwArgs)
        {
            try
            {
                var obj = xfwArgs.NATSData.Data;
                var body = obj.GetBody();
                var eqpId = body.GetVal(CItems.EqpID);
                var waferId = body.GetVal(CItems.waferId);
                var passNo = body.GetVal(CItems.PassDieCount);
                var position = waferId.Substring(waferId.Length - 2);
                //ClientInfo.EQPInfo.LotList[0].State = lotStatus;
                var waferinfo = ClientInfo.EQPInfo.LotList[0].SlotMaps.FirstOrDefault(o => string.IsNullOrEmpty(o.waferCode) ? false : o.WaferCode.Contains(waferId));
                if (waferinfo == null) return;
                waferinfo.passNo = int.Parse(passNo);
                waferinfo.waferState = WaferState.WaferEnd.ToString();
            }
            catch (Exception ex)
            {
                XfwContext.EapLogger.Information(ex, $"ClientService.SendLotEnd() Execute Error.");
            }
        }
        public Return SendRemoveLot(string eqpId, string portId, string userid)
        {
            EAPClient cq = new EAPClient();
            // requestClient = cq.Config.GetSection("RequestClient").Get<string>();
            var retMsg = new Return();
            try
            {
                if (EQPStatus.MagazineList.Contains(EQPStatus.currenteqpid))
                    MainWindow.magazineDic.Remove(EQPStatus.currenteqpid);
                if (EQPStatus.TrayList.Contains(EQPStatus.currenteqpid))
                {
                    MainWindow.trayDic.Remove(EQPStatus.currenteqpid);
                }
                if (EQPStatus.TrayTransferList.Contains(EQPStatus.currenteqpid))
                {
                    MainWindow.traytransferDic.Remove(EQPStatus.currenteqpid);
                }
                var request = new Request() { Header = XfwUtils.CreateHeader(MsgNameSendRemoveLot, requestClient) };
                request.Body.AddString(CItems.EqpID, eqpId);
                request.Body.AddString(CItems.PortID, portId);
                request.Body.AddString(CItems.UserID, userid);
                ClientInfo.EQPInfo.LotList[0].LOSSINFOLIST = new List<Core.Entities.LOSSINFOLIST>();
                LossSN.LossInfoList = new List<Core.Entities.LOSSINFOLIST>();
                LossSN.count = 0;
                var strText = XfwUtils.Serialization(request.GetSerializationObject());
                context = XfwContext.GetMqContextByEAP(requestClient);
                var res = context.Request(strText);
                if (res != null)
                {
                    retMsg = res.GetReturnObject();
                }
                XfwContext.EapLogger.Information($"EAPClient.SendRemoveLot() Execute. ReturnCode: {retMsg.ReturnCode}, ReturnMessage: {retMsg.ReturnMessage}");
            }
            catch (Exception ex)
            {
                retMsg.SetReturnNG(ex.Message);
                XfwContext.EapLogger.Error(ex, $"EAPClient.SendRemoveLot() Execute Error.");
            }
            return retMsg;
        }
        public Return ChangeLanguage(string language)
        {
            EAPClient cq = new EAPClient();
            string[] eqplst = cq.Config.GetSection("ToolIds").Get<string>().Split(',');
            List<string> EqpList = new List<string>();
            foreach (var item in eqplst)
            {
                EqpList.Add(item.Split('+')[0]);
            }
            var retMsg = new Return();
            try
            {

            }
            catch (Exception ex)
            {
                retMsg.SetReturnNG(ex.Message);
                XfwContext.EapLogger.Error(ex, $"EAPClient.ChangeLanguage() Execute Error.");
            }
            return retMsg;
        }
        public Return Login(string username, string password, string facilityId)
        {
            var retMsg = new Return();
            try
            {
                var request = new Request() { Header = XfwUtils.CreateHeader(MsgNameLogin, requestClient) };
                request.Body.AddString(CItems.UserName, username);
                request.Body.AddString(CItems.Password, password);
                request.Body.AddString(CItems.FacilityId, facilityId);
                var strText = XfwUtils.Serialization(request.GetSerializationObject());
                context = XfwContext.GetMqContextByEAP(requestClient);
                var res = context.Request(strText);
                if (res != null)
                {
                    retMsg = res.GetReturnObject();
                }
                var messages = TranslateMsg.GetTranslation("LoginRequest");
                if (messages != null)
                {
                    ClientInfo.EQPInfo.LotList[0].ShowMsg(Core.Enums.MessageOrigin.EAP, Core.Enums.MessageType.Info, messages[RunService.Current.ClientLanguage]);
                    XfwContext.DbLogger.Information("EAPClient Tip:"+messages[RunService.Current.ClientLanguage]);
                }
                XfwContext.EapLogger.Information($"EAPClient.Login() Execute. ReturnCode: {retMsg.ReturnCode}, ReturnMessage: {retMsg.ReturnMessage}");
            }
            catch (Exception ex)
            {
                retMsg.SetReturnNG(ex.Message);
                XfwContext.EapLogger.Error(ex, $"EAPClient.Login() Execute Error.");
            }
            return retMsg;
        }
        /// <summary>
        /// 获取lot信息
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public Return GetCarrierLotInfo(object obj)
        {
            Dictionary<string, string> ss = obj as Dictionary<string, string>;
            EAPClient cq = new EAPClient();
            var retMsg = new Return();
            try
            {
                var request = new Request() { Header = XfwUtils.CreateHeader(MsgNameGetCarrierLotInfo, requestClient) };
                request.Body.AddString(CItems.LotID, ss["Lotid"]);
                request.Body.AddString(CItems.EqpID, ss["eqpname"]);
                request.Body.AddString(CItems.UserName, ss["UserId"]);
                request.Body.AddString(CItems.FacilityId, ss["facilityId"]);
                request.Body.AddString(CItems.ProberCardId, ss["proberCardId"]);
                request.Body.AddString(CItems.Alignment, ss["alignment"]);
                request.Body.AddString(CItems.TestMode, ss["testmode"]);
                var strText = XfwUtils.Serialization(request.GetSerializationObject());
                context = XfwContext.GetMqContextByEAP(requestClient);
                context.Configure.Timeout = 50000;
                Stopwatch sw = new Stopwatch();
                sw.Start();
                var res = context.Request(strText);
                sw.Stop();
                XfwContext.EapLogger.Debug($"调用{MsgNameGetCarrierLotInfo}接口，耗时为:{sw.ElapsedMilliseconds}");
                if (res != null)
                {
                    var aaa = res.GetVal<string>(CItems.UnitInfo);
                    retMsg.ReturnMessage = res.GetResponse().ToString();
                }
                var messages = TranslateMsg.GetTranslation("LotInfoRequest");
                if (messages != null)
                {
                    ClientInfo.EQPInfo.LotList[0].ShowMsg(Core.Enums.MessageOrigin.EAP, Core.Enums.MessageType.Info, messages[RunService.Current.ClientLanguage]);
                    XfwContext.DbLogger.Information("EAPClient Tip:" + messages[RunService.Current.ClientLanguage]);
                }
                XfwContext.EapLogger.Information($"EAPClient.GetCarrierLotInfo() Execute. ReturnCode: {retMsg.ReturnCode}, ReturnMessage: {retMsg.ReturnMessage}");
            }
            catch (Exception ex)
            {
                retMsg.SetReturnNG(ex.Message);
                XfwContext.EapLogger.Error(ex, $"EAPClient.GetCarrierLotInfo() Execute Error.");
            }
            return retMsg;
        }

        public Return GetCarrierLotInfo(string lotId, string equipmentId, string userId, string facilityId, string proberCardId, string alignment)
        {
            EAPClient cq = new EAPClient();
            //requestClient = cq.Config.GetSection("RequestClient").Get<string>();
            var retMsg = new Return();
            try
            {
                var request = new Request() { Header = XfwUtils.CreateHeader(MsgNameGetCarrierLotInfo, requestClient) };
                request.Body.AddString(CItems.LotID, lotId);
                request.Body.AddString(CItems.EqpID, equipmentId);
                request.Body.AddString(CItems.UserName, userId);
                request.Body.AddString(CItems.FacilityId, facilityId);
                request.Body.AddString(CItems.ProberCardId, proberCardId);
                request.Body.AddString(CItems.Alignment, alignment);
                var strText = XfwUtils.Serialization(request.GetSerializationObject());



                context = XfwContext.GetMqContextByEAP(requestClient);
                // context.Configure.Timeout = 50000;
                Stopwatch sw = new Stopwatch();
                sw.Start();


                var res = context.Request(strText);
                sw.Stop();
                XfwContext.EapLogger.Debug($"调用{MsgNameGetCarrierLotInfo}接口，耗时为:{sw.ElapsedMilliseconds}");
                if (res != null)
                {
                    var aaa = res.GetVal<string>(CItems.UnitInfo);
                    retMsg.ReturnMessage = res.GetResponse().ToString();
                    //res.GetResponse
                }
                var messages = TranslateMsg.GetTranslation("LotInfoRequest");
                if (messages != null)
                {
                    ClientInfo.EQPInfo.LotList[0].ShowMsg(Core.Enums.MessageOrigin.EAP, Core.Enums.MessageType.Info, messages[RunService.Current.ClientLanguage]);
                    XfwContext.DbLogger.Information("EAPClient Tip:" + messages[RunService.Current.ClientLanguage]);
                }
                XfwContext.EapLogger.Information($"EAPClient.GetCarrierLotInfo() Execute. ReturnCode: {retMsg.ReturnCode}, ReturnMessage: {retMsg.ReturnMessage}");
            }
            catch (Exception ex)
            {
                retMsg.SetReturnNG(ex.Message);
                XfwContext.EapLogger.Error(ex, $"EAPClient.GetCarrierLotInfo() Execute Error.");
            }
            return retMsg;
        }
        /// <summary>
        /// 开始online作业
        /// </summary>
        /// <param name="eqpId"></param>
        /// <returns></returns>
        public Return StartProgram(string testerid, string proberid)
        {
            EAPClient cq = new EAPClient();
            //requestClient = cq.Config.GetSection("RequestClient").Get<string>();
            var retMsg = new Return();
            try
            {
                var request = new Request() { Header = XfwUtils.CreateHeader(MsgNameStartProgram, requestClient) };
                request.Body.AddString(CItems.TesterID, testerid);
                request.Body.AddString(CItems.ProberID, proberid);
                var strText = XfwUtils.Serialization(request.GetSerializationObject());
                context = XfwContext.GetMqContextByEAP(requestClient);
                var res = context.Request(strText);
                if (res != null)
                {
                    retMsg = res.GetReturnObject();
                }
                XfwContext.EapLogger.Information($"EAPClient.StartProgram() Execute. ReturnCode: {retMsg.ReturnCode}, ReturnMessage: {retMsg.ReturnMessage}");
            }
            catch (Exception ex)
            {
                retMsg.SetReturnNG(ex.Message);
                XfwContext.EapLogger.Error(ex, $"EAPClient.StartProgram() Execute Error.");
            }
            return retMsg;
        }

        /// <summary>
        /// 暂停offline作业
        /// </summary>
        /// <param name="eqpId"></param>
        /// <returns></returns>
        public Return SendStopProcess(string testerid, string proberid)
        {
            EAPClient cq = new EAPClient();
            var retMsg = new Return();
            try
            {
                var request = new Request() { Header = XfwUtils.CreateHeader(MsgNameSendStopProcess, requestClient) };
                request.Body.AddString(CItems.TesterID, testerid);
                request.Body.AddString(CItems.ProberID, proberid);
                var strText = XfwUtils.Serialization(request.GetSerializationObject());
                context = XfwContext.GetMqContextByEAP(requestClient);
                var res = context.Request(strText);
                if (res != null)
                {
                    retMsg = res.GetReturnObject();
                }
                XfwContext.EapLogger.Information($"EAPClient.StopProgram() Execute. ReturnCode: {retMsg.ReturnCode}, ReturnMessage: {retMsg.ReturnMessage}");
            }
            catch (Exception ex)
            {
                retMsg.SetReturnNG(ex.Message);
                XfwContext.EapLogger.Error(ex, $"EAPClient.StopProgram() Execute Error.");
            }
            return retMsg;
        }

        /// <summary>
        /// 人工手动出站
        /// </summary>
        /// <param name="eqpId"></param>
        /// <returns></returns>
        public Return TrackOutByUser(string eqpId, List<Core.Entities.LOSSINFOLIST> lossList)
        {
            EAPClient cq = new EAPClient();
            //  requestClient = cq.Config.GetSection("RequestClient").Get<string>();
            var retMsg = new Return();
            try
            {
                var request = new Request() { Header = XfwUtils.CreateHeader(MsgNameTrackOutByUser, requestClient) };
                request.Body.AddString(CItems.EqpID, eqpId);
                request.Body.AddList<Core.Entities.LOSSINFOLIST>(CItems.LossList, lossList);
                ClientInfo.EQPInfo.LotList[0].LOSSINFOLIST = new List<Core.Entities.LOSSINFOLIST>();
                LossSN.LossInfoList = new List<Core.Entities.LOSSINFOLIST>();
                LossSN.count = 0;
                var strText = XfwUtils.Serialization(request.GetSerializationObject());
                context = XfwContext.GetMqContextByEAP(requestClient);
                var res = context.Request(strText);
                if (res != null)
                {
                    retMsg = res.GetReturnObject();
                }
                XfwContext.EapLogger.Information($"EAPClient.TrackOutByUser() Execute. ReturnCode: {retMsg.ReturnCode}, ReturnMessage: {retMsg.ReturnMessage}");
            }
            catch (Exception ex)
            {
                retMsg.SetReturnNG(ex.Message);
                XfwContext.EapLogger.Error(ex, $"EAPClient.TrackOutByUser() Execute Error.");
            }
            return retMsg;
        }
        /// <summary>
        /// 发送心跳
        /// </summary>
        /// <param name="eqpId"></param>
        /// <returns></returns>
        public Return SendHeartBeat(string eqpId)
        {
            var retMsg = new Return();
            try
            {
                var request = new Request() { Header = XfwUtils.CreateHeader(HeartBeat, requestClient) };
                request.Body.AddString(CItems.EqpID, eqpId);
                var strText = XfwUtils.Serialization(request.GetSerializationObject());
                context = XfwContext.GetMqContextByEAP(requestClient);
                var res = context.Request(strText);
                if (res != null)
                {
                    retMsg.ReturnCode = res.GetReturnCode();
                    retMsg.ReturnMessage = res.GetResponse().ToString();
                }
                XfwContext.EapLogger.Information($"EAPClient.SendHeartBeat() Execute. ReturnCode: {retMsg.ReturnCode}, ReturnMessage: {retMsg.ReturnMessage}");
            }
            catch (Exception ex)
            {
                retMsg.SetReturnNG(ex.Message);
                XfwContext.EapLogger.Error(ex, $"EAPClient.SendHeartBeat() Execute Error.");
            }
            return retMsg;
        }
        /// <summary>
        /// 筛选片
        /// </summary>
        /// <param name="eqpid"></param>
        /// <param name="waferid"></param>
        /// <param name="mesid"></param>
        /// <returns></returns>
        public Return SelectWaferID(string eqpid, string waferid, string mesid, string IsFullmeasurement, string NeedlemarkValue, string UnitidList=null,string IsAll="N")
        {
            var retMsg = new Return();
            try
            {
                var request = new Request() { Header = XfwUtils.CreateHeader(MsgNameSelectWaferID, requestClient) };
                request.Body.AddString(CItems.ProberID, eqpid);
                request.Body.AddString(CItems.SelectWaferID, waferid);
                request.Body.AddString(CItems.MesWaferID, mesid);
                request.Body.AddString(CItems.IsFullmeasurement, IsFullmeasurement);
                request.Body.AddString(CItems.NeedleMarkDetectionWaferId, NeedlemarkValue);
                request.Body.AddString(CItems.UnitidList, UnitidList);
                request.Body.AddString("IsAll", IsAll);
                var strText = XfwUtils.Serialization(request.GetSerializationObject());
                context = XfwContext.GetMqContextByEAP(requestClient);
                var messages = TranslateMsg.GetTranslation("SelectWaferIDRequest");
                if (messages != null && messages.Count != 0)
                {
                    ClientInfo.EQPInfo.LotList[0].ShowMsg(Core.Enums.MessageOrigin.EAP, Core.Enums.MessageType.Info, messages[RunService.Current.ClientLanguage]);
                    XfwContext.DbLogger.Information("EAPClient Tip:" + messages[RunService.Current.ClientLanguage]);
                }
                var res = context.Request(strText);
                if (res != null)
                {
                    retMsg = res.GetReturnObject();
                }

                XfwContext.EapLogger.Information($"EAPClient.SelectWaferID() Execute. ReturnCode: {retMsg.ReturnCode}, ReturnMessage: {retMsg.ReturnMessage}");
            }
            catch (Exception ex)
            {
                retMsg.SetReturnNG(ex.Message);
                XfwContext.EapLogger.Error(ex, $"EAPClient.SelectWaferID() Execute Error.");
            }
            return retMsg;
        }


        public Return SelectWaferIDFP3000(string eqpid, string waferid, string testMode, string IsFullmeasurement, string NeedlemarkValue, string UnitidList = null, string IsAll = "N")
        {
            var retMsg = new Return();
            try
            {
                var request = new Request() { Header = XfwUtils.CreateHeader(MsgNameSelectWaferID, requestClient) };
                request.Body.AddString(CItems.ProberID, eqpid);
                request.Body.AddString(CItems.SelectWaferID, waferid);
                request.Body.AddString(CItems.TestMode, testMode);
                request.Body.AddString(CItems.IsFullmeasurement, IsFullmeasurement);
                request.Body.AddString(CItems.NeedleMarkDetectionWaferId, NeedlemarkValue);
                request.Body.AddString(CItems.UnitidList, UnitidList);
                request.Body.AddString("IsAll", IsAll);
                var strText = XfwUtils.Serialization(request.GetSerializationObject());
                context = XfwContext.GetMqContextByEAP(requestClient);
                var messages = TranslateMsg.GetTranslation("SelectWaferIDRequest");
                if (messages != null && messages.Count != 0)
                {
                    ClientInfo.EQPInfo.LotList[0].ShowMsg(Core.Enums.MessageOrigin.EAP, Core.Enums.MessageType.Info, messages[RunService.Current.ClientLanguage]);
                    XfwContext.DbLogger.Information("EAPClient Tip:" + messages[RunService.Current.ClientLanguage]);
                }
                var res = context.Request(strText);
                if (res != null)
                {
                    retMsg = res.GetReturnObject();
                }

                XfwContext.EapLogger.Information($"EAPClient.SelectWaferID() Execute. ReturnCode: {retMsg.ReturnCode}, ReturnMessage: {retMsg.ReturnMessage}");
            }
            catch (Exception ex)
            {
                retMsg.SetReturnNG(ex.Message);
                XfwContext.EapLogger.Error(ex, $"EAPClient.SelectWaferID() Execute Error.");
            }
            return retMsg;
        }


        /// <summary>
        /// 指定针痕检测waferid
        /// </summary>
        /// <param name="needleMarkDetectionWaferId"></param>
        /// <returns></returns>
        public Return SelectNeedleMarkDetectionWaferId(string needleMarkDetectionWaferId)
        {
            var retMsg = new Return();
            try
            {
                var request = new Request() { Header = XfwUtils.CreateHeader(MsgNameNeedleMarkDetectionWaferId, requestClient) };
                request.Body.AddString(CItems.NeedleMarkDetectionWaferId, needleMarkDetectionWaferId);
                var strText = XfwUtils.Serialization(request.GetSerializationObject());
                context = XfwContext.GetMqContextByEAP(requestClient);
                var messages = TranslateMsg.GetTranslation("SelectNeedleMarkDetectionWaferIdRequest");
                if (messages != null && messages.Count != 0)
                {
                    ClientInfo.EQPInfo.LotList[0].ShowMsg(Core.Enums.MessageOrigin.EAP, Core.Enums.MessageType.Info, messages[RunService.Current.ClientLanguage]);
                    XfwContext.DbLogger.Information("EAPClient Tip:" + messages[RunService.Current.ClientLanguage]);
                }
                var res = context.Request(strText);
                if (res != null)
                {
                    retMsg = res.GetReturnObject();
                }

                XfwContext.EapLogger.Information($"EAPClient.SelectWaferID() Execute. ReturnCode: {retMsg.ReturnCode}, ReturnMessage: {retMsg.ReturnMessage}");
            }
            catch (Exception ex)
            {
                retMsg.SetReturnNG(ex.Message);
                XfwContext.EapLogger.Error(ex, $"EAPClient.SelectWaferID() Execute Error.");
            }
            return retMsg;
        }/// <summary>
         /// 客户端消除alarm
         /// </summary>
         /// <param name="alarmid"></param>
         /// <returns></returns>
        public Return ClearAlarm(string alarmid)
        {
            var retMsg = new Return();
            try
            {
                var request = new Request() { Header = XfwUtils.CreateHeader(MsgNameClearAlarm, requestClient) };
                request.Body.AddString(CItems.AlarmID, alarmid);
                var strText = XfwUtils.Serialization(request.GetSerializationObject());
                context = XfwContext.GetMqContextByEAP(requestClient);
                var res = context.Request(strText);
                if (res != null)
                {
                    retMsg = res.GetReturnObject();
                }
                XfwContext.EapLogger.Information($"EAPClient.ClearAlarm() Execute. ReturnCode: {retMsg.ReturnCode}, ReturnMessage: {retMsg.ReturnMessage}");
            }
            catch (Exception ex)
            {
                retMsg.SetReturnNG(ex.Message);
                XfwContext.EapLogger.Error(ex, $"EAPClient.ClearAlarm() Execute Error.");
            }
            return retMsg;
        }
        /// <summary>
        /// 发送针痕确认用户信息
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="remark"></param>
        /// <param name="Messageinfo"></param>
        /// <returns></returns>
        public Return SendNeedMardUserInfo(string userid, string remark, string Messageinfo)
        {
            var retMsg = new Return();
            try
            {
                var request = new Request() { Header = XfwUtils.CreateHeader(MsgNameSendNeedMardUserInfo, requestClient) };
                request.Body.AddString(CItems.UserName, userid);
                request.Body.AddString(CItems.NeedleTypeMessageRemark, remark);
                request.Body.AddString(CItems.NeedleTypeMessage, Messageinfo);
                var strText = XfwUtils.Serialization(request.GetSerializationObject());
                context = XfwContext.GetMqContextByEAP(requestClient);
                var res = context.Request(strText);
                if (res != null)
                {
                    retMsg = res.GetReturnObject();
                }
                XfwContext.EapLogger.Information($"EAPClient.SendNeedMardUserInfo() Execute. ReturnCode: {retMsg.ReturnCode}, ReturnMessage: {retMsg.ReturnMessage}");
            }
            catch (Exception ex)
            {
                retMsg.SetReturnNG(ex.Message);
                XfwContext.EapLogger.Error(ex, $"EAPClient.SendNeedMardUserInfo() Execute Error.");
            }
            return retMsg;
        }
    }
}
